package com.itgaoshu.hospitalproject.mapper;

import com.itgaoshu.hospitalproject.bean.*;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ProjecttypeMapper {
    //查询项目大类的方法
    List<Projecttype> findAllProjecttype(String projectName);
    //添加项目大类的方法
    @Insert("insert into projecttype values(null,#{projectName})")
    int addProjecttype(Projecttype projecttype);
    //查看这个项目大类寻不存在
    @Select("select count(1) from projecttype where projectName=#{projectName}")
    int count(Projecttype projecttype);


    //查询所有病床的方法
    List<Bed> findAllBed(String bedname);
    //添加床位的方法
    @Insert("insert into bed(bedId,bedname,price,departmentId) values(null,#{bedname},#{price},#{departmentId})")
    int addBed(Bed bed);
    //查询这个病床是否存在的方法
    @Select("select count(1) from bed where bedname=#{bedname}")
    int count1(Bed bed);
    //修改病床的方法
    @Update("update bed set price=#{price},departmentId=#{departmentId} where bedId=#{bedId}")
    int editBed(Bed bed);
    //删除病床的方法
    @Delete("delete from bed where bedId=#{bedId}")
    int deleteBed(int bedId);
    //查询这个病床上还有没有病人
    @Select("select count(*) from bed b,register r where r.bednum=b.bedid and b.bedid=#{bedid}")
    int count2(int bedId);



    //查询收费类型
    List<Moneytype> findAllMoneytype(String moneytype);
    //添加收费类型
    @Insert(" insert into moneytype(moneytype,percent)values(#{moneytype},#{percent})")
    int addMoneytype(Moneytype moneytype);
    //查询该类型是否存在
    @Select("select  count(*) from moneytype where moneytype=#{moneytype}")
    int count3(Moneytype moneytype);
    //修改收费类型
    @Update("update moneytype set percent=#{percent} where moneyId=#{moneyId}")
    int editMoneytype(Moneytype moneytype);
    //删除收费类型
    @Delete("delete from moneytype where moneyId=#{moneyId}")
    int deleteMoneytype(int moneyId);






    //查询门诊
    List<Outpatienttype> findAllOutpatienttype(String projectName);
    //添加
    @Insert("insert into outpatienttype(projectName, unit, bigprojectId, price,ostate) values (#{projectName}, #{unit}, #{bigprojectId}, #{price},#{ostate})")
    int addOutpatienttype(Outpatienttype outpatienttype);
    //查看是否已经存在
    @Select("select  count(*) from outpatienttype where projectName=#{projectName}")
    int count4(Outpatienttype outpatienttype);
    //修改
    @Update("update outpatienttype set price=#{price},unit=#{unit},bigprojectId=#{bigprojectId},ostate=#{ostate} where outpatientId=#{outpatientId}")
    int editOutpatienttype(Outpatienttype outpatienttype);
    //删除
    @Delete("delete from Outpatienttype where outpatientId=#{outpatientId}")
    int deleteOutpatienttype(int outpatientId);


    //住院收费
    List<Inoutpatienttype> findAllInoutpatienttype(String projectName);
    //添加收费项目
    @Insert("insert into Inoutpatienttype(projectName,price,unit,bigprojectId)values(#{projectName},#{price},#{unit},#{bigprojectId})")
    int addInoutpatienttype(Inoutpatienttype inoutpatienttype);
    //查询这个类型存不存在
    @Select("select  count(*) from Inoutpatienttype where projectName=#{projectName}")
    int count5(Inoutpatienttype inoutpatienttype);
    //修改
    @Update("update Inoutpatienttype set price=#{price},unit=#{unit},bigprojectId=#{bigprojectId} where inoutpatientId=#{inoutpatientId}")
    int editInoutpatienttype(Inoutpatienttype inoutpatienttype);
    //删除
    @Delete("delete from Inoutpatienttype where inoutpatientId=#{inoutpatientId}")
    int deleteInoutpatienttype(int inoutpatientId);
}
